package com.lagou.edu.listener;

import com.lagou.edu.config.MyConfig;
import com.lagou.edu.scan.AnnotationApplicationContext;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class MyWebListener implements ServletContextListener {



    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent)  {
        System.out.println("web 容器启动");
        try {
            AnnotationApplicationContext applicationContext = new AnnotationApplicationContext(MyConfig.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        System.out.println("web 容器关闭");
    }
}
